package org.example.bean;


import java.util.Objects;

/**
 * 封装路径结点类，字段包括：坐标、G 值、F 值、父结点，实现 Comparable 接口，方便优先队列排序
 */
public  class Node {
    public int x, y;
    public Node parent;
    public int g; // 从起点到当前节点的实际代价
    public int h; // 从当前节点到终点的启发式代价（预估代价）
    public int f; // f = g + h

    public Node(int x, int y) {
        this.x = x;
        this.y = y;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        Node node = (Node) obj;
        return x == node.x && y == node.y;
    }

    @Override
    public int hashCode() {
        return Objects.hash(x, y);
    }
}
